package com.cw.war.ui
{
	import com.cw.ui.LoadingUI;
	
	import flash.display.MovieClip;

	/**
	 * loading条 
	 * @author elvisjiang
	 * 
	 */
	public class LoadingBox extends AbstractPopup
	{
		private static var instance : LoadingBox;
		
		private static var isShow:Boolean;
		
		public static function show () : void
		{
			if (instance == null)
			{
				instance = new LoadingBox ();
				instance.open ();
			}
		}
		public static function updateState(data:Object):void
		{
			instance.updateState(data);
		}
		private var _state:Object;
		public function updateState(data:Object):void
		{
			_state = data.state;
			mc.swfNoTxt.text = _state.currentIndex + "/" + _state.totalSwfNum;
			mc.eachSwfTxt.text = _state.currentSwfLoadedBytes + "k/" + _state.currentSwfTotalBytes+"k";
//			mc.eachSwfTxt.text = _state.percent+"/100";
			mc.swfNoMC.width = (_state.currentIndex)*290/Number(_state.totalSwfNum);
			
			mc.eachSwfMC.width = (_state.currentSwfLoadedBytes)*290/Number(_state.currentSwfTotalBytes);
//			trace(mc.swfNoMC.width,mc.eachSwfMC.width );
//			trace(_state.currentIndex," "+_state.totalSwfNum,"/",_state.currentSwfLoadedBytes," "+_state.currentSwfTotalBytes);
		}
		
		public static function remove():void
		{
			if(instance)
			{
				instance.close();
				instance = null;
			}
		}
		
		private var mc : LoadingUI;
		
		/**
		 * 创建一个<code>LoadingBox</code>组件。
		 * @param text		要显示的文本。
		 */
		public function LoadingBox ()
		{
			this.mc = new LoadingUI ();
			this.addChild(mc);
			this.setModal ( true );
		}
	}
}